home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr29 / mfil125.zip / GETREADM.CMD < prev    next >
OS/2 REXX Batch file  |  1994-05-13  |  10KB  |  317 lines

  1. /* getreadm.cmd*/
  2. /* echo off*/
  3. parse upper arg qual drive path file ext
  4. fqual = STRIP(qual)
  5. ldriv = STRIP(drive)
  6. lpath = STRIP(path)
  7. lfile = STRIP(file)
  8. lext  = STRIP(ext)
  9.      
  10.  
  11.  
  12. /*
  13.  
  14.     This code has been pirated from Virexx.cmd by Ronald Van Iwaarden
  15.     1:104/338@fidonet 12 May, 1994
  16. */
  17. /* ---------------------------------------------------------------------------*/
  18. /*   - - - - - - - - - -   C O N F I G U R A T I O N - - - - - - - - - - -    */
  19. /* -----  Set these variables for your System ------------------------------- */
  20.  
  21. /* 1) LISTS  (lists of file extensions and how to deal with them)                                                                */
  22. /* ***** THESE MUST BE UPPER CASE OR THEY WONT WORK !!!!!    ****** */
  23.  
  24. arc_list='.ZIP .LZH .ARC .ARJ .ZOO'     /* list of defined achives */
  25.  
  26. /* 2) VARIABLES */
  27.  
  28. /* 3) PATHS (paths to various files and directories needed by VIREXX */
  29. /* ****NOTE**** Change only UPPER CASE PARTS*/
  30. tempdir  = 'e:\tmp\readme'      /* dir for testing lnode = 1,2 ect.*/
  31.  
  32.  
  33. /* 4) COMMANDS (Command lines for various programs called by VIREXX)*/
  34. /*    NOTE: Virexx appends the filename to the end of the archiver commands*/
  35. /*    so the space at the end is important*/
  36.  
  37. lh_command='lh x /o /i '                /* command to extract .lzh file*/
  38.                                         /* this ones for 32bit LH2 2.12*/
  39. zip_command1 ='unzip -oj '              /* command to extract .ZIP files*/
  40.                                         /* with version 1.x signature*/
  41.                                         /* this ones for PKUNZIP2 1.02*/
  42. zip_command2 ='unzip -oj '              /* command to extract .ZIP files*/
  43.                                         /* with version 2.x signature*/
  44.                                         /* this ones for InfoZip unzip 5.0*/
  45. arj_command ='unarj e '                 /* unarj command for Robert Jungs*/
  46.                                         /* Demo version 2.10 Unarj*/
  47. /* arj_command ='gnunarj x '*/          /* unarj command for 32bit GNU port*/
  48.                                         /* of R. Jungs Demo Unarj 2.30*/
  49. arc_command ='arc2 xo '                 /* command to extract archive using*/
  50.                                         /* SEA's ARC2 ver 6.00*/
  51. zoo_command ='zoo e:O '                 /* command to extract archive using*/
  52.                                         /* ZOO 2.1 (renamed to ZOO2.exe)*/
  53. comment_command = 'zip -z -k '          /* command to add comment to .zip file*/
  54.  
  55. zipdir = ''                             /* path to arcive subdirectory */
  56.  
  57. /* 5) SWITCHES (switches for various functions. Use 1 for ON, 0 for OFF)*/
  58.  
  59. zipcomment = 1                          /* Add bbs comment to .zip files*/
  60. dbase      = 1                          /* write entry to file database*/
  61. /* -------------------------------------------------------------------------- */
  62. /*    - - - - -  E N D    O F    C O N F I G U R A T I O N  - - - - - - -     */
  63. /* ---------------------------- Main Program -------------------------------- */
  64. /*trace all*/
  65. call initialize                        /* initialize program */
  66. fullname = fqual                       /* full pathname to file(s) */
  67.  
  68. /* Look for all files with the specified name*/
  69.  
  70.  
  71.  
  72. call SysFileTree fullname,'lfile','FSO'
  73. /* If any exist then process them*/
  74. if lfile.0 > 0 then do
  75.  
  76.  
  77.  
  78. /* Perform check for all of the files*/
  79. /* This version is made for generic scans of subdirectories*/
  80. do filecnt = 1 to lfile.0
  81.  
  82. /* Get the first/next file to process*/
  83. fullname = TRANSLATE(lfile.filecnt)     /* full pathname to file */
  84.  
  85. filename = lfile||lext
  86.  
  87.  
  88. lpath = ldrive||lpath
  89.  
  90.  
  91. select
  92.   when POS(lext,arc_list)>0 then
  93.     call unarchive
  94.  
  95. end /* select */
  96.  
  97. call readme
  98.  
  99. end /* Loop for all files*/
  100. end /* Files exist*/
  101. cleanup:
  102.   call RxFuncDrop 'SysFileTree'
  103.  
  104.  
  105. exit
  106.  
  107. /* ------------ end -  main program ------------------ */
  108.  
  109. /*     Possible Status Values
  110.  
  111.         GOOD     = No problems
  112.         BAD      = Failed to Unarchive 
  113.         INFECTED = Failed Virus Scan 
  114.         UNKNOWN  = File extension was not of any type defined
  115.         EXE      = File was .exe or .com (I treat these with a great 
  116.                     deal of suspicion! )
  117.         NOEXT    = file had no extension i.e. 'filename.'
  118.         OLD      = archive contained files older than oldest date
  119.         PASS     = Scan and PASS thru (use for other extension you
  120.                    want to pass automatically (GIF, TIF or whatever)
  121.         REJECT   = file was in the reject list.  Deleted and the user
  122.                    is sent a warning note
  123. */
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. /* ----- Subroutine Initialize ----------------------- */
  131. initialize:
  132.  if lext = '' then
  133.    call USAGE
  134.  dontask = '/N'
  135.  call RxFuncAdd 'SysFileTree','RexxUtil','SysFileTree'
  136.  call RxFuncAdd 'SysMkDir','RexxUtil','SysMkDir'
  137.  call RxFuncAdd 'SysRmDir','RexxUtil','SysRmDir'
  138.                                    /* make sure Rexxutils loaded */
  139.  call SysFileTree tempdir,'dir','DO'
  140.  if dir.0 = 0 then
  141.    call SysMkDir tempdir
  142.  
  143.  if stream(tempdir||'\*.*','c','query exist')  <> '' then
  144.    'ERASE 'tempdir'\*.* 'dontask   /* cleanup test dir */
  145.  tempdir.0 = 0 /* No arcs within arcs yet*/
  146.  
  147.  archsize = 0
  148.  nested = NO                                 /* clear nested */
  149.  ZIPTYPE =''
  150.  
  151.  
  152. return
  153.  
  154. /* ----- End - Initialize ---------------------------- */
  155.  
  156. /* ----- Subroutine Unarchive ------------------------ */
  157.  
  158. unarchive:
  159.  ffname = fullname
  160.  fname = filename
  161.  testdir = tempdir
  162.  signature = CHARIN(ffname,1,6)
  163.  temp = stream(ffname,'c','close')
  164.  Select
  165.  
  166.    when (substr(signature,1,5) = 'PK') then do  /* version 2.x zip file    */
  167.      call unzip2
  168.    end /* do */
  169.  
  170.    when (substr(signature,1,4) = 'PK') then do  /* version 1.x zip file    */
  171.      call unzip1
  172.    end /* do */
  173.  
  174.    when (substr(signature,3,3) = '-lh'  ) then do      /* .lzh file          */
  175.      call unlzh
  176.    end /* do */
  177.  
  178.    when (substr(signature,1,2) = '`Ω'   ) then do      /* .arj file          */
  179.      call unarj
  180.    end /* do */
  181.  
  182.    when (substr(signature,1,3) = 'ZOO'  ) then do      /* .zoo file          */
  183.      call unzoo
  184.    end /* do */
  185.  
  186.    when lext = '.ARC' then do                            /* .arc file           */
  187.      call unarc
  188.    end /* do */
  189.  
  190.    otherwise do
  191.      status = 'BAD'
  192.    end /* do */
  193.  
  194. end /* select */
  195.  
  196.  
  197. return
  198.  
  199. /* ----------- End - unarchive -----------------------------*/
  200.  
  201. /* ------- edit or view readme files ----------------------- */
  202.  
  203. readme:
  204.  fileinfo = tempdir'\read.me'
  205.  if stream(fileinfo,'c','query exist') <> '' then do 
  206.  
  207.    'e' tempdir'\read.me'
  208.  
  209.  end /* do */
  210.  
  211.  fileinfo = tempdir'\readme'
  212.  if stream(fileinfo,'c','query exist') <> '' then do 
  213.  
  214.    'e' tempdir'\read.me'
  215.  
  216.  end /* do */
  217.  
  218.  fileinfo = tempdir'\readme.txt'
  219.  if stream(fileinfo,'c','query exist') <> '' then do 
  220.  
  221.    'e' tempdir'\read.me'
  222.  
  223.  end /* do */
  224.  
  225. return
  226.  
  227.  
  228.  
  229. /* ----------end --  scanner ------------- */
  230.  
  231.  
  232. /* ------ Unzip - run unzip on filename ------- */
  233. unzip1:
  234.   'CD 'testdir
  235.   zipdir||zip_command1' 'ffname' readme read.me readme.txt'/* unzip file */
  236. return
  237.  
  238. /* end unzip1 */
  239. /* ------ Unzip2 - run unzip on version 2.x filename ------- */
  240. unzip2:
  241.  'CD 'testdir
  242.  zipdir||zip_command2' 'ffname' readme read.me readme.txt'/* unzip file */
  243. return  
  244.  
  245. /* end unzip2 */
  246.  
  247.  
  248. /* ------ Unzoo - run zoo on filename ------- */
  249. unzoo:
  250.   'CD 'testdir
  251.   zipdir||zoo_command' 'ffname' readme read.me readme.txt'
  252. return
  253.  
  254. /* end unzoo */
  255.  
  256.  
  257. /* ---------  unarj -- run unarj on filename --------------- */
  258. unarj:
  259.      /* written for Robert Jung's Unarj 2.10                                */
  260.      /* this section will copy the file to the test file dir and also copy  */
  261.      /* unarj to the same directory, run unarj and cleanup afterwards. If   */
  262.      /* your test dir is on a different drive be sure to fix this section   */
  263.  
  264.   'CD 'testdir
  265. /*     unarj e fname                                     /* unarj file        */
  266. */
  267.   zipdir||arj_command' 'ffname' readme read.me readme.txt'
  268.  
  269. return
  270.  
  271. /* end unarj */
  272.  
  273. /* ----------- unlzh -- unlzh filename ----------- */
  274.          
  275. unlzh:
  276.   /* written for LH32  2.21    */
  277.   'COPY 'ffname testdir                          /* copy file to test dir  */
  278.   'CD 'testdir
  279.   zipdir||lh_command' 'ffname' readme read.me readme.txt' /* unlzh file */
  280. return
  281.  
  282. /* end unlzh */
  283.  
  284. /* ----- unarc -- unarc filename using ARC2 ---- */
  285.  
  286. unarc:
  287.   /* written for ARC2 6.00p                                              */
  288.   /* this section will copy the file to the test file dir and also copy  */
  289.   /* arc2 to the same directory, run arc2 and cleanup afterwards. If     */
  290.   /* your test dir is on a different drive be sure to fix this section   */
  291.  
  292.   'COPY 'ffname testdir                          /* copy file to test dir  */
  293.   'CD 'testdir
  294.   zipdir||arc_command' 'ffname' readme read.me readme.txt'  /* unarc file   */
  295. return
  296.  
  297. /* end unarc  */
  298.  
  299.  
  300.  
  301.  
  302. USAGE:
  303. say ' '
  304. say ' getreadm.cmd a .cmd file to extract and view a readme file'
  305. say ' '
  306. say ' USAGE: getreadm d:\path\filename.exe d: path\ filename .ext'
  307. say ' '
  308. say ' path\   = path to file to be checked INCLUDING trailing \'
  309. say ' '
  310. say ' filename   = the name of the file with no path or extension'
  311. say ' '
  312. say ' .ext       = the file extension including the . '
  313. say ' '
  314. say ' '
  315. signal CLEANUP
  316. return
  317.